#pragma once
#include "LocalVertexFactory.h"
#include "Runtime/BattleFirePrefix.h"
#include "MeshVertexBuffers.h"
namespace Alice{
    class StaticMesh;
    /** The maximum number of static mesh LODs allowed. */
    #define MAX_STATIC_MESH_LODS 8
    /**
     * A set of static mesh triangles which are rendered with the same material.
     */
    struct FStaticMeshSection
    {
        /** The index of the material with which to render this section. */
        int32 MaterialIndex;

        /** Range of vertices and indices used when rendering this section. */
        uint32 FirstIndex;
        uint32 NumTriangles;
        uint32 MinVertexIndex;
        uint32 MaxVertexIndex;

        /** If true, collision is enabled for this section. */
        bool bEnableCollision;

        /** If true, this section will cast a shadow. */
        bool bCastShadow;
        /** If true, this section will be visible in ray tracing effects. */
        bool bVisibleInRayTracing;
        /** If true, this section will affect lighting methods that use Distance Fields. */
        bool bAffectDistanceFieldLighting;
        /** If true, this section will be considered opaque in ray tracing effects. */
        bool bForceOpaque;

        /** Constructor. */
        FStaticMeshSection()
            : MaterialIndex(0)
            , FirstIndex(0)
            , NumTriangles(0)
            , MinVertexIndex(0)
            , MaxVertexIndex(0)
            , bEnableCollision(false)
            , bCastShadow(true)
            , bVisibleInRayTracing(true)
            , bAffectDistanceFieldLighting(true)
            , bForceOpaque(false)
        {
        }
    };
    struct StaticMeshVertexFactories
    {
        StaticMeshVertexFactories()
        {
            
        }
        LocalVertexFactory mVertexFactory;
        void InitResources(const MeshVertexBuffers& VertexBuffers, uint32 LODIndex, const StaticMesh* inOwner);
        void InitVertexFactory(const MeshVertexBuffers& VertexBuffers, LocalVertexFactory& InOutVertexFactory, uint32 LODIndex, const StaticMesh* inOwnerMesh, bool bInOverrideColorVertexBuffer);
    };
    struct StaticMeshLODResource{
        MeshVertexBuffers* mMeshVertexBuffers;
        std::vector<FStaticMeshSection> mSections;
        void InitResources(StaticMesh* inParent, int32 LODIndex);
    };
    class StaticMeshResource{
    public:
        StaticMeshLODResource* mStaticMeshLODResource;
        StaticMeshVertexFactories* mStaticMeshLODVertexFactories;
        void InitResources(StaticMesh*inOwner);
    };
}